<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.4 -->
        <link href="/favicon.ico" type="image/x-icon" rel="shortcut icon" />
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/static/admin/css/animate.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/static/admin/css/ourstyle.css?v=4.0.0" rel="stylesheet">
    <link href="/public/static/admin/css/ratuo.css" rel="stylesheet">

    <!-- 全局js -->
    <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <!-- 自定义js -->
    <script src="/public/static/admin/js/content.js?v=1.0.0"></script>
    <!-- jQuery Validation plugin javascript-->
    <script src="/public/static/admin/plugins/ckeditor/ckeditor.js"></script>
    <script src="/public/static/admin/plugins/ckfinder/ckfinder.js"></script>

    <!-- iCheck -->
    <script src="/public/static/admin/js/plugins/iCheck/icheck.min.js"></script>
    <script src="/public/static/admin/js/plugins/layer/layer.min.js"></script>

    <script src="/public/static/admin/js/rt_common.js?v=4.0.1"></script> 
    <script src="/public/static/admin/js/rt_post.js?v=4.0.0"></script>
    <script src="/public/static/admin/js/jquery.validate.js"></script>
    <script src="/public/static/admin/plugins/laydate/laydate.js"></script>
    <script src="/public/static/admin/js/jquery-form.js"></script>

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>订单列表</h5>
                </div>
                <div class="ibox-content">
                    <div class="box-header">  
                        <div class="panel-body">
                            <form action="{:url('Admin/order/export_order')}" id="search-form2" class="form-inline" method="post">
                                <div class="form-group" style="width:100%;margin-bottom:10px;">
                                    <label class="control-label" for="input-order-id">收货人</label>
                                        <input type="text" name="consignee" placeholder="收货人" id="input-member-id" class="form-control">
                                    <label class="control-label" for="input-order-id">订单编号</label>
                                        <input type="text" name="order_sn" placeholder="订单编号" id="input-order-id" class="form-control">
                                    <label class="control-label" for="input-date-added">下单日期</label>
                                        <input type="text" name="timegap" value="{$begin}-{$end}" placeholder="下单日期"  id="add_time" class="form-control">
                                </div>
                                <div class="form-group" style="width:100%;margin-bottom:10px;">
                                    <select name="pay_status" class="form-control">
                                    	<option value="">选择支付状态</option>
                                        <option value="0">未支付</option>
              							<option value="1">已支付</option>
                                    </select>
                                    <select name="shipping_status" class="form-control">
                                    	<option value="">选择发货状态</option>
                                        <option value="0">未发货</option>
              							<option value="1">已发货</option>
              							<option value="2">部分发货</option>
                                    </select>
                                    <select name="order_status" class="form-control" style="display: none;">
                                        <option value="">选择订单状态</option>
                                        <volist name="order_status" id="v" key="k">
                                            <option value="{$k-1}">{$v}</option>
                                        </volist>
                                    </select>
                                    <input type="hidden" name="user_id" value="{$user_id}">
                                    <input type="hidden" name="order_by" value="order_id">
                                    <input type="hidden" name="sort" value="desc">
                                </div>
                                <br/>
                                <div class="form-group" style="width:100%;">
                                	<a href="javascript:void(0)" onclick="ajax_get_table('search-form2','/index.php/Admin/Order/ajaxIndex')" id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</a>
                                	<a href="javascript:void(0);" onclick="openLayer('{:url('Admin/order/add_order')}','添加订单')" class="btn btn-primary pull-right" style="display: none;"><i class="fa fa-search"></i>添加订单</a>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div id="ajax_return">
                        
                    </div>

                </div>
            </div>
        </div>
    </div>        <!-- /.row -->

    <!-- /.content -->
</div>
<input id="handle_status" value="" hidden="hidden">
<input id="handle_url" value="" hidden="hidden">
<!-- /.content-wrapper -->
<script>
    $(document).ready(function(){
        ajax_get_table('search-form2','/index.php/Admin/Order/ajaxIndex');
        
		// $('#add_time').daterangepicker({
		// 	format:"YYYY/MM/DD",
		// 	singleDatePicker: false,
		// 	showDropdowns: true,
		// 	minDate: '2015/01/01',
		// 	maxDate: '2035/01/01',
		// 	startDate:'2015/01/01',
		//     locale : {
	 //            applyLabel : '确定',
	 //            cancelLabel : '取消',
	 //            fromLabel : '起始时间',
	 //            toLabel : '结束时间',
	 //            customRangeLabel : '自定义',
	 //            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
	 //            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
	 //            firstDay : 1
	 //        }
		// });
    });

    function openLayer(url,name){
        parent.layer.open({
            type: 2,
            title: name,
            shade: 0.5,
            shadeClose : false,
            maxmin: true, //开启最大化最小化按钮
            area: ['80%', '90%'],
            content: url,
            end : function(){
                var handle_status = $("#handle_status").val();
                if(handle_status == '1'){
                    window.location.href = location.href;
                }
            }
        });
    }




    // ajax 抓取页面
    // function ajax_get_table(tab,page){
    //     cur_page = page;
    //         $.ajax({
    //             type : "POST",
    //             url:"/index.php/Admin/order/ajaxindex/p/"+page,
    //             data : $('#'+tab).serialize(),
    //             success: function(data){
    //                 $("#ajax_return").html('');
    //                 $("#ajax_return").append(data);
    //             }
    //         });
    // }
    // ajax 抓取页面 form 为表单id  page 为当前第几页
    function ajax_get_table(form,url){
        // cur_page = page; //当前页面 保存为全局变量
        // var info = $('#page_info').val();
        $.ajax({
            type : "POST",
            url:url,
            data : $('#'+form).serialize(),// 你的formid
            success: function(data){
                $("#ajax_return").html('');
                $("#ajax_return").append(data);
            }
        });
        return false;
    }

    // 点击排序
    function sort(field) {
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }

    function del(id){
        parent.layer.confirm('确定要删除吗？', function(){
            $.ajax({
                url:"/index.php?m=Admin&c=order&a=delete_order&id="+id,
                success: function(v){
                    var v =  eval('('+v+')');
                    parent.layer.msg(v.msg, {icon: 2,time: 1000});
                    if(v.hasOwnProperty('status') && (v.status == 1))
                        ajax_get_table('search-form2',cur_page);
                }
            });
        });
    }

    function delHtml(obj,id) {
        top.layer.confirm('确定要删除吗？',{
            icon : 3,
            btn:['确定','取消'],
        } , function(){
            $.ajax({
                url : "/index.php/Admin/order/delete_order",
                type : "post",
                data : {id:id},
                dataType : "json",
                success:function(data){
                    if (data.status == 0) { 
                        top.layer.msg(data.msg,{icon:2});
                    } else {
                        top.layer.msg(data.msg,{icon:1});
                        $(obj).parent().parent().remove();
                        $('#html'+id).remove();
                    }
                }
            });
        } , function(){
            layer.close(); //再执行关闭 
        })
    }

</script>
</body>
</html>